

package com.thxrinfo.operate.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig4cloud.pig.common.core.util.R;
import com.pig4cloud.pig.common.log.annotation.SysLog;
import com.thxrinfo.operate.api.entity.MerchantChangeLog;
import com.thxrinfo.operate.service.MerchantChangeLogService;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;


/**
 * 商户余额变更记录表
 *
 * @author ct
 * @date 2023-03-15 13:42:16
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/merchantchangelog" )
@Tag(name = "商户余额变更记录表管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class MerchantChangeLogController {

    private final  MerchantChangeLogService merchantChangeLogService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param merchantChangeLog 商户余额变更记录表
     * @return
     */
    @Operation(summary = "分页查询", description = "分页查询")
    @GetMapping("/page" )
    @PreAuthorize("@pms.hasPermission('operate_merchantchangelog_get')" )
    public R getMerchantChangeLogPage(Page page, MerchantChangeLog merchantChangeLog) {
        return R.ok(merchantChangeLogService.page(page, merchantChangeLog));
    }


    /**
     * 通过id查询商户余额变更记录表
     * @param id id
     * @return R
     */
    @Operation(summary = "通过id查询", description = "通过id查询")
    @GetMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('operate_merchantchangelog_get')" )
    public R getById(@PathVariable("id" ) Long id) {
        return R.ok(merchantChangeLogService.getById(id));
    }

    /**
     * 新增商户余额变更记录表
     * @param merchantChangeLog 商户余额变更记录表
     * @return R
     */
    @Operation(summary = "新增商户余额变更记录表", description = "新增商户余额变更记录表")

    @SysLog("新增商户余额变更记录表" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('operate_merchantchangelog_add')" )
    public R save(@RequestBody MerchantChangeLog merchantChangeLog) {
        return R.ok(merchantChangeLogService.save(merchantChangeLog));
    }

//    /**
//     * 修改商户余额变更记录表
//     * @param merchantChangeLog 商户余额变更记录表
//     * @return R
//     */
//    @Operation(summary = "修改商户余额变更记录表", description = "修改商户余额变更记录表")
//    @SysLog("修改商户余额变更记录表" )
//    @PutMapping
//    @PreAuthorize("@pms.hasPermission('operate_merchantchangelog_edit')" )
//    public R updateById(@RequestBody MerchantChangeLog merchantChangeLog) {
//        return R.ok(merchantChangeLogService.updateById(merchantChangeLog));
//    }
//
//    /**
//     * 通过id删除商户余额变更记录表
//     * @param id id
//     * @return R
//     */
//    @Operation(summary = "通过id删除商户余额变更记录表", description = "通过id删除商户余额变更记录表")
//    @SysLog("通过id删除商户余额变更记录表" )
//    @DeleteMapping("/{id}" )
//    @PreAuthorize("@pms.hasPermission('operate_merchantchangelog_del')" )
//    public R removeById(@PathVariable Long id) {
//        return R.ok(merchantChangeLogService.removeById(id));
//    }

}
